<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>经营质量分析表</title>
  <style type="text/css">
  </style>
</head>
<body>
  <div class="layui-fluid">   
    <div class="layui-card">
      <!-- 查询区域  -->
      <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">统计月份</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="sts_month_id"  name="stsMonth" readonly>
            </div>
          </div>
          <div class="layui-inline">
            	<label class="layui-form-label">公司主体</label>
            	<div class="layui-input-inline" style="width:260px;">
              		<select name="orgTypeAndId" id="query_select_orgId" lay-filter="query_select_orgId" lay-search >
	              		<c:if test="${not empty orgInfos }">
	              			<c:forEach items="${orgInfos}" var="org">
	              				<option value="${org.id}-${org.types}" <c:if test="${org.id == bindOrgId }">selected</c:if>>${org.compName }</option>
		            		</c:forEach>
	              		</c:if>
	              	</select>
            	</div>
          	</div>
          <shiro:hasPermission name="LIST_QA_CONSOLE">
	          <div class="layui-inline">
	            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-qa-console-search">
	              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
	            </button>
	          </div>
          </shiro:hasPermission>
        </div>
      </div>
  	  <!-- 按钮区域  -->
      <div class="layui-form">
        <!-- 数据表单 -->
        <div style="text-align: center; margin-top:15px;  margin-bottom:18px;">
	          <div class="layui-inline">
	          	<span style="font-size:15px;letter-spacing:1px;font-weight:bold;"><span id="qa_title_pre_id"></span>经营质量分析报表</span>
          	  </div>
        </div>
        <div style="text-align: center; margin-top:-25px;  margin-bottom:18px;">
	          <div class="layui-inline" style="float:right;margin-bottom:2px;margin-right:0px;">
		         	<label class="layui-form-label">单位</label> 
	         	 	<div class="layui-inline" style="width:70px;">
		         	<select id="money_unit_ctrl" class="layui-select" lay-filter="money_unit_ctrl">
			    	<option value='1'>元</option>
					<option value="2" selected>万元</option>
					<option value="3">亿元</option>
				  </select>
				  </div>
          	  </div>
        </div>
        <hr/>
        <table id="LAY-qa-console-manage" lay-filter="LAY-qa-console-manage"></table>
      </div>
    </div>
    <div class="layui-card">
    	<div class="layui-card-body">
    		<div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
              	<ul class="layui-tab-title">
                	<li class="layui-this" id="caeLi" lay-id="cae"><B>合同额</B></li>
                	<li lay-id="cap"><B>融资额</B></li>
                	<li lay-id="invest"><B>投资额</B></li>
                	<li lay-id="profit"><B>管理净利润</B></li>
                	<!-- <li lay-id="cashin"><B>投资性现金流入</B></li>
                	<li lay-id="cashout"><B>投资性现金流出</B></li> -->
              	</ul>
              	<div class="layui-tab-content">
                	<div class="layui-tab-item layui-show">
			      		<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-cae">
			          		<div carousel-item id="LAY-index-cae">
			             		<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
			          		</div>
			      		</div>
			      	</div>
			      	<div class="layui-tab-item">
			      		<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-cap">
			          		<div carousel-item id="LAY-index-cap">
			             		<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
			          		</div>
			      		</div>
			      	</div>
			      	<div class="layui-tab-item">
			      		<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-invest">
			          		<div carousel-item id="LAY-index-invest">
			             		<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
			          		</div>
			      		</div>
			      	</div>
			      	<div class="layui-tab-item">
			      		<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-profit">
			          		<div carousel-item id="LAY-index-profit">
			             		<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
			          		</div>
			      		</div>
			      	</div>
			      	<div class="layui-tab-item">
			      		<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-cashin">
			          		<div carousel-item id="LAY-index-cashin">
			             		<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
			          		</div>
			      		</div>
			      	</div>
			      	<div class="layui-tab-item">
			      		<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-cashout">
			          		<div carousel-item id="LAY-index-cashout">
			             		<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
			          		</div>
			      		</div>
			      	</div>
      			</div>
      		</div>
    	</div>
   	</div>
    <div class="layui-card">
    	<div class="layui-card-body">
    		<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-month">
              	<div carousel-item id="LAY-index-month">
                	<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
              	</div>
            </div>
    	</div>
    </div>
  </div>

  <script>
  	layui.config({
    	base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index' //主入口模块
  	}).use(['index', 'table', 'set', 'laydate', 'carousel', 'echarts', 'senior', 'element'], function(){
    	var $ = layui.$
    	,form = layui.form
    	,table = layui.table
    	,laydate = layui.laydate
    	,element = layui.element
    	,carousel = layui.carousel
        ,echarts = layui.echarts;
    	
    	var tempValue = "";// 用于存放最新的时间
    	
    	//tab重新渲染宽度
    	element.on('tab(component-tabs-brief)', function(data){
             var index = data.index;
             var year;
             if(tempValue==""){
             	year = $('#sts_month_id').val().substr(0, 4);
             }else {
            	year = tempValue.substr(0, 4);
             }
             var orgTypeAndId = $('#query_select_orgId').val();
             // 第一页
             if(index === 0) {
                 rendernormcae(0,year,orgTypeAndId);
             }else if(index === 1){
                 rendernormcap(0,year,orgTypeAndId);
             }else if(index === 2){
                 rendernorminvest(0,year,orgTypeAndId);
             }else if(index === 3){
                 rendernormprofit(0,year,orgTypeAndId);
             }else if(index === 4){
                 rendernormcashin(0,year,orgTypeAndId);
             }else if(index === 5){
                 rendernormcashout(0,year,orgTypeAndId);
             }
    	});
    	
	    laydate.render({
	      elem: '#sts_month_id'
	      ,type: 'month'
	      ,btns: ['now', 'confirm']
	      ,format:'yyyy年MM月'
	      ,value: layui.util.toDateString(new Date().getTime() - 2592000000 , 'yyyy年MM月') //30天前
	      ,done:function(value){
      		  var orgTypeAndId = $('#query_select_orgId').val();
      		  var orgType = orgTypeAndId.split("-")[1];
      		  var tabId = $(".layui-tab-title .layui-this").attr("lay-id");
      		  tempValue = value;// 设置
      		  if(orgType == '2'||orgType == '3'){
      			  $("#caeLi").hide();
      			  $('#LAY-index-cae').hide();
      			  if(tabId == 'cae'){
   			 		  element.tabChange('component-tabs-brief', 'cap');
    			  }else{
   			 		  element.tabChange('component-tabs-brief', tabId);
    			  }
      		  }else{
      			  $("#caeLi").show();
      			  $('#LAY-index-cae').show();
   			 	  element.tabChange('component-tabs-brief', tabId);
      		  }
      		  renderNormcol(0,value,orgTypeAndId);
	      	  table.reload('LAY-qa-console-manage', {page: {curr: 1},
			 	 where: {'stsMonth':value,'orgTypeAndId':$('#query_select_orgId').val()}
		      });
	      	  // 修改tip显示
	    	  $('#qa_title_pre_id').html($('select[id="query_select_orgId"] option:selected').text()+"-"+value+"-");
	      }
	    });
		// 默认填充
	    $('#qa_title_pre_id').html($('select[id="query_select_orgId"] option:selected').text()+"-"+$('#sts_month_id').val()+"-");
	    
		form.on('select(query_select_orgId)', function(data){
      		var select_text = data.elem[data.elem.selectedIndex].text;
    		var month = $('#sts_month_id').val();
    		var orgType = data.value.split("-")[1];
    		var tabId = $(".layui-tab-title .layui-this").attr("lay-id");
   		  	if(orgType == '2'||orgType == '3'){
   			  	$("#caeLi").hide();
   			 	$('#LAY-index-cae').hide();
    			if(tabId == 'cae'){
   			 		element.tabChange('component-tabs-brief', 'cap');
    			}else{
   			 		element.tabChange('component-tabs-brief', tabId);
    			}
   		  	}else{
   			  	$("#caeLi").show();
   			 	$('#LAY-index-cae').show();
   			 	element.tabChange('component-tabs-brief', tabId);
   		  	}
   		 	renderNormcol(0,month,data.value);
   		 	table.reload('LAY-qa-console-manage', {page: {curr: 1},
		 		where: {'stsMonth':$('#sts_month_id').val(),'orgTypeAndId':$('#query_select_orgId').val()}
	      	});
   			// 修改tip显示  
   		 	$('#qa_title_pre_id').html($('#sts_month_id').val()+"-"+select_text+"-");
    	});
		      	
		var colsInit = [
				 {type: 'checkbox', fixed: 'left',hide:true}
				,{field: 'aimType', title: '指标',templet: function(d){
					if(d.aimType=='1'){
				  		//return '<a href="javascript:void(0)" lay-event="selfCaeView" style="text-decoration:underline;color:#009688;">合同额</a>';
				  		return '合同额';
				  	}else if(d.aimType=='2'){
				  		return '<a href="javascript:void(0)" lay-event="targetView" style="text-decoration:underline;color:#009688;">融资额</a>';
				    }else if(d.aimType=='3'){
				  		return '<a href="javascript:void(0)" lay-event="targetView" style="text-decoration:underline;color:#009688;">投资额</a>';
				    }else if(d.aimType=='4'){
				  		return '<a href="javascript:void(0)" lay-event="targetView" style="text-decoration:underline;color:#009688;">管理净利润</a>';
				    }else if(d.aimType=='5'){
				  		return '管理费用';
				    }else if(d.aimType=='6'){
				  		return '管理费率';
				    }else if(d.aimType=='7'){
				  		return '(废弃指标)营销费用';
				    }else if(d.aimType=='8'){
				  		return '(废弃指标)营销费率';
				    }else if(d.aimType=='9'){
				    	return '(废弃指标)现金流入';
				  		//return '<a href="javascript:void(0)" lay-event="targetView" style="text-decoration:underline;color:#009688;">投资性现金流入</a>';
				    }else if(d.aimType=='10'){
				    	return '(废弃指标)现金流出';
				  		//return '<a href="javascript:void(0)" lay-event="targetView" style="text-decoration:underline;color:#009688;">投资性现金流出</a>';
				    }
					}}
				,{field: 'curMonthPlan', title: '月度计划（元）',hide:true,templet: function(d){
					    return formatCurrency(d.curMonthPlan);
				}}
				,{field: 'curMonthPlanTts', title: '月度计划（万元）',templet: function(d){
					    return formatCurrency(d.curMonthPlanTts);
				}}
				,{field: 'curMonthPlanHms', title: '月度计划（亿元）',hide:true,templet: function(d){
					    return d.curMonthPlanHms;
				}}
				,{field: 'curMonthFinish', title: '月度完成（元）',hide:true,templet: function(d){
						if(d.curMonthFinish < d.curMonthPlan && d.aimType !='5' && d.aimType !='6' && d.aimType !='7' && d.aimType !='8'){
							return '<font color=red>'+formatCurrency(d.curMonthFinish)+'</font>';
						}else{
					    	return formatCurrency(d.curMonthFinish);
						}
				}}
				,{field: 'curMonthFinishTts', title: '月度完成（万元）',templet: function(d){
						if(d.curMonthFinish < d.curMonthPlan  && d.aimType !='5' && d.aimType !='6' && d.aimType !='7' && d.aimType !='8'){
							return '<font color=red>'+formatCurrency(d.curMonthFinishTts)+'</font>';
						}else{
					    	return formatCurrency(d.curMonthFinishTts);
						}
				}}
				,{field: 'curMonthFinishHms', title: '月度完成（亿元）',hide:true,templet: function(d){
						if(d.curMonthFinish < d.curMonthPlan  && d.aimType !='5' && d.aimType !='6' && d.aimType !='7' && d.aimType !='8'){
							return '<font color=red>'+d.curMonthFinishHms+'</font>';
						}else{
					    	return d.curMonthFinishHms;
						}
				}}
				,{field: 'curMonthRate', title: '月度完成率',templet: function(d){
					    if(d.curMonthRate==null){
					    	return global_null_tip;
					    }
						return d.curMonthRate + '%';
				}}
				,{field: 'yearAddupPlan', title: '月累计划（元）',hide:true,templet: function(d){
					    return formatCurrency(d.yearAddupPlan);
				}}
				,{field: 'yearAddupPlanTts', title: '月累计划（万元）',templet: function(d){
					    return formatCurrency(d.yearAddupPlanTts);
				}}
				,{field: 'yearAddupPlanHms', title: '月累计划（亿元）',hide:true,templet: function(d){
					    return d.yearAddupPlanHms;
				}}
				,{field: 'yearAddupFinish', title: '月累完成（元）',hide:true,templet: function(d){
					    return formatCurrency(d.yearAddupFinish);
				}}
				,{field: 'yearAddupFinishTts', title: '月累完成（万元）',templet: function(d){
					    return formatCurrency(d.yearAddupFinishTts);
				}}
				,{field: 'yearAddupFinishHms', title: '月累完成（亿元）',hide:true,templet: function(d){
					    return d.yearAddupFinishHms;
				}}
				,{field: 'yearAddupRate', title: '月累完成率',templet: function(d){
						if(d.yearAddupRate==null){
					    	return global_null_tip;
					    }
						return d.yearAddupRate + '%';
				}}
				,{field: 'yearAllPlan', title: '年度计划（元）',hide:true,templet: function(d){
					    return formatCurrency(d.yearAllPlan);
				}}
				,{field: 'yearAllPlanTts', title: '年度计划（万元）',templet: function(d){
					    return formatCurrency(d.yearAllPlanTts);
				}}
				,{field: 'yearAllPlanHms', title: '年度计划（亿元）',hide:true,templet: function(d){
					    return d.yearAllPlanHms;
				}}
				,{field: 'yearAllRate', title: '年度完成率',templet: function(d){
						if(d.yearAllRate==null){
					    	return global_null_tip;
					    }
						return d.yearAllRate + '%';
				}}
	       ];
		
		/** 渲染判断  **/
		function customerCols(){
			var unit = $('#money_unit_ctrl').val();
			if(unit==1){
				// 元
				colsInit[2].hide = false;
				colsInit[5].hide = false;
				colsInit[9].hide = false;
				colsInit[12].hide = false;
				colsInit[16].hide = false;
				// 万元
				colsInit[3].hide = true;
				colsInit[6].hide = true;
				colsInit[10].hide = true;
				colsInit[13].hide = true;
				colsInit[17].hide = true;
				// 亿元
				colsInit[4].hide = true;
				colsInit[7].hide = true;
				colsInit[11].hide = true;
				colsInit[14].hide = true;
				colsInit[18].hide = true;
			}
			if(unit==2){
				// 元
				colsInit[2].hide = true;
				colsInit[5].hide = true;
				colsInit[9].hide = true;
				colsInit[12].hide = true;
				colsInit[16].hide = true;
				// 万元
				colsInit[3].hide = false;
				colsInit[6].hide = false;
				colsInit[10].hide = false;
				colsInit[13].hide = false;
				colsInit[17].hide = false;
				// 亿元
				colsInit[4].hide = true;
				colsInit[7].hide = true;
				colsInit[11].hide = true;
				colsInit[14].hide = true;
				colsInit[18].hide = true;
			}
			if(unit==3){
				// 元
				colsInit[2].hide = true;
				colsInit[5].hide = true;
				colsInit[9].hide = true;
				colsInit[12].hide = true;
				colsInit[16].hide = true;
				// 万元
				colsInit[3].hide = true;
				colsInit[6].hide = true;
				colsInit[10].hide = true;
				colsInit[13].hide = true;
				colsInit[17].hide = true;
				// 亿元
				colsInit[4].hide = false;
				colsInit[7].hide = false;
				colsInit[11].hide = false;
				colsInit[14].hide = false;
				colsInit[18].hide = false;
			}
		}
		// 切换单位时 重新渲染		
		form.on('select(money_unit_ctrl)', function(data){
			// 处理列显示
			customerCols();
			// 表单
	    	table.render({
	      		elem: '#LAY-qa-console-manage'
	      		,url: basePath + '/qaConsole/queryDataByCondition' //请求数据接口
	      		,cols: [colsInit]
	      		,page: false
	      		,limit: 10
	      		,where: {'stsMonth':$('#sts_month_id').val(),'orgTypeAndId':$('#query_select_orgId').val()}
	    	});
    	});
		
    	// 表单
    	table.render({
      		elem: '#LAY-qa-console-manage'
      		,url: basePath + '/qaConsole/queryDataByCondition' //请求数据接口
      		,cols: [colsInit]
      		,page: false
      		,limit: 10
      		,where: {'stsMonth':$('#sts_month_id').val(),'orgTypeAndId':$('#query_select_orgId').val()}
    	});
    
    	<shiro:hasPermission name="LIST_QA_CONSOLE">
	    	//监听搜索
	    	form.on('submit(LAY-qa-console-search)', function(data){
		      	//执行重载
		      	table.reload('LAY-qa-console-manage', {page: {curr: 1},
		        	where: trimData(data)
		      	});
	    	});
    	</shiro:hasPermission>
    
    	// 监听操作列
    	table.on('tool(LAY-qa-console-manage)', function(obj){
      		var data = obj.data;
      		var orgId = '';
			var orgType = data.orgType;
			var tabName = '';
			if(orgType == '1'){
				orgId = data.hrOrgSuperId;
				tabName = '区域';
			}else if(orgType == '2'){
				orgId = data.hrOrgAreaId;
				tabName = '项目';
			}
			var stsMonth = $('#sts_month_id').val();
			var orgName = $('select[id="query_select_orgId"] option:selected').text();
 			if(obj.event === 'selfCaeView'){
	       		parent.layui.index.openTabsPage(basePath + '/qaConsole/selfCaeList?orgId='+orgId+'&orgType='+orgType+'&stsMonth='+stsMonth+'&orgName='+orgName,'合同额（'+tabName+'）');
	   		}else if(obj.event === 'targetView'){
				var aimType = data.aimType;
	   			var targetName = '';
				if(aimType == '2'){
					targetName = '融资额';
				}else if(aimType == '3'){
					targetName = '投资额';
				}else if(aimType == '4'){
					targetName = '管理净利润';
				}else if(aimType == '9'){
					targetName = '投资性现金流入';
				}else if(aimType == '10'){
					targetName = '投资性现金流出';
				}
				if(orgType != '3'){
	       			parent.layui.index.openTabsPage(basePath + '/qaConsole/targetList?orgId='+orgId+'&orgType='+orgType+'&stsMonth='+stsMonth+'&orgName='+orgName+'&aimType='+aimType+'&targetName='+targetName,targetName+'（'+tabName+'）');
				}else{
					var proCode = data.proCode;
					parent.layui.index.openTabsPage(basePath + '/qaConsole/qaProDetail?proCode='+proCode+'&aimType='+aimType,targetName+'（项目信息）');
				}
	   		}
    	});
    	
    	//合同额
        function rendernormcae(index,year,orgTypeAndId){
        	var monthArr = [];
        	var planAmount = [];
			var finishAmount = [];
        	$.ajax({
    			type : "POST", //提交方式  
    			async: false,
    			url : "${ctx}/qaConsole/getQaAmountByYearAndId",//路径  
    			data : {
    				"year" : year,
    				"orgTypeAndId" : orgTypeAndId,
    				"aimType": 1
    			},//数据，这里使用的是Json格式进行传输  
    			success : function(result) {//返回数据根据结果进行相应的处理 
    				if(result.flag==true){
    					var qaAmounts = result.qaAmounts;
    					layui.$.each(qaAmounts ,function (index, amount){
    						monthArr.push(amount.belongsMonth+"月");                     
    						planAmount.push(amount.curMonthPlanTts);                     
    						finishAmount.push(amount.curMonthFinishTts);
                        });
   						if(monthArr.length == 0){
   							monthArr = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
   						}
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			} 
    		});
	        var echnormline = [], normline = [
	          {
	            title : {
	              text: $('select[id="query_select_orgId"] option:selected').text()+"-"+year+'年-合同额月度走势',
	              x: 'center',
	              subtext: '单位：万元'
	            },
	            tooltip : {
	              trigger: 'axis'
	            },
	            legend: {
	              data:['月度计划','月度完成'],
	              x: 'right'
	            },
	            calculable : true,
	            xAxis : [
	              {
	                type : 'category',
	                boundaryGap : false,
	                data : monthArr
	              }
	            ],
	            yAxis : [
	              {
	                type : 'value'
	              }
	            ],
	            series : [
	              {
	                name:'月度计划',
	                type:'line',
	                data:planAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              },
	              {
	                name:'月度完成',
	                type:'line',
	                itemStyle: {
	                	normal:{color:'#d48265'}
	                },
	                data:finishAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              }
	            ]
	          }
	        ]
	        ,elemnormline = $('#LAY-index-cae').children('div');
        	if(!elemnormline[index]) return;
          	echnormline[index] = echarts.init(elemnormline[index], layui.echartsTheme);
          	echnormline[index].setOption(normline[index]);
          	window.onresize = echnormline[index].resize;
        };
        
    	var year = $('#sts_month_id').val().substr(0, 4);
    	var orgTypeAndId = $('#query_select_orgId').val();
        rendernormcae(0,year,orgTypeAndId);
        
	    //融资额
        function rendernormcap(index,year,orgTypeAndId){
        	var monthArr = [];
        	var planAmount = [];
			var finishAmount = [];
        	$.ajax({
    			type : "POST", //提交方式  
    			async: false,
    			url : "${ctx}/qaConsole/getQaAmountByYearAndId",//路径  
    			data : {
    				"year" : year,
    				"orgTypeAndId" : orgTypeAndId,
    				"aimType": 2
    			},//数据，这里使用的是Json格式进行传输  
    			success : function(result) {//返回数据根据结果进行相应的处理 
    				if(result.flag==true){
    					var qaAmounts = result.qaAmounts;
    					layui.$.each(qaAmounts ,function (index, amount){
    						monthArr.push(amount.belongsMonth+"月");                     
    						planAmount.push(amount.curMonthPlanTts);                     
    						finishAmount.push(amount.curMonthFinishTts);
                        });
   						if(monthArr.length == 0){
   							monthArr = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
   						}
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			} 
    		});
	        var echnormcap = [], normcap = [
	          {
	            title : {
	              text: $('select[id="query_select_orgId"] option:selected').text()+"-"+year+'年-融资额月度走势',
	              x: 'center',
	              subtext: '单位：万元'
	            },
	            tooltip : {
	              trigger: 'axis'
	            },
	            legend: {
	              data:['月度计划','月度完成'],
	              x: 'right'
	            },
	            calculable : true,
	            xAxis : [
	              {
	                type : 'category',
	                boundaryGap : false,
	                data : monthArr
	              }
	            ],
	            yAxis : [
	              {
	                type : 'value'
	              }
	            ],
	            series : [
	              {
	                name:'月度计划',
	                type:'line',
	                data:planAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              },
	              {
	                name:'月度完成',
	                type:'line',
	                itemStyle: {
	                	normal:{color:'#d48265'}
	                },
	                data:finishAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              }
	            ]
	          }
	        ]
	        ,elemnormcap = $('#LAY-index-cap').children('div');
        	if(!elemnormcap[index]) return;
          	echnormcap[index] = echarts.init(elemnormcap[index], layui.echartsTheme);
          	echnormcap[index].setOption(normcap[index]);
          	window.onresize = echnormcap[index].resize;
        }
        
	    //投资额
        function rendernorminvest(index,year,orgTypeAndId){
        	var monthArr = [];
        	var planAmount = [];
			var finishAmount = [];
        	$.ajax({
    			type : "POST", //提交方式  
    			async: false,
    			url : "${ctx}/qaConsole/getQaAmountByYearAndId",//路径  
    			data : {
    				"year" : year,
    				"orgTypeAndId" : orgTypeAndId,
    				"aimType": 3
    			},//数据，这里使用的是Json格式进行传输  
    			success : function(result) {//返回数据根据结果进行相应的处理 
    				if(result.flag==true){
    					var qaAmounts = result.qaAmounts;
    					layui.$.each(qaAmounts ,function (index, amount){
    						monthArr.push(amount.belongsMonth+"月");                     
    						planAmount.push(amount.curMonthPlanTts);                     
    						finishAmount.push(amount.curMonthFinishTts);
                        });
   						if(monthArr.length == 0){
   							monthArr = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
   						}
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			} 
    		});
	        var echnorminvest = [], norminvest = [
	          {
	            title : {
	              text: $('select[id="query_select_orgId"] option:selected').text()+"-"+year+'年-投资额月度走势',
	              x: 'center',
	              subtext: '单位：万元'
	            },
	            tooltip : {
	              trigger: 'axis'
	            },
	            legend: {
	              data:['月度计划','月度完成'],
	              x: 'right'
	            },
	            calculable : true,
	            xAxis : [
	              {
	                type : 'category',
	                boundaryGap : false,
	                data : monthArr
	              }
	            ],
	            yAxis : [
	              {
	                type : 'value'
	              }
	            ],
	            series : [
	              {
	                name:'月度计划',
	                type:'line',
	                data:planAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              },
	              {
	                name:'月度完成',
	                type:'line',
	                itemStyle: {
	                	normal:{color:'#d48265'}
	                },
	                data:finishAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              }
	            ]
	          }
	        ]
	        ,elemnorminvest = $('#LAY-index-invest').children('div');
	        if(!elemnorminvest[index]) return;
          	echnorminvest[index] = echarts.init(elemnorminvest[index], layui.echartsTheme);
          	echnorminvest[index].setOption(norminvest[index]);
          	window.onresize = echnorminvest[index].resize;
        };
        
	    //管理净利润
        function rendernormprofit(index,year,orgTypeAndId){
        	var monthArr = [];
        	var planAmount = [];
			var finishAmount = [];
        	$.ajax({
    			type : "POST", //提交方式  
    			async: false,
    			url : "${ctx}/qaConsole/getQaAmountByYearAndId",//路径  
    			data : {
    				"year" : year,
    				"orgTypeAndId" : orgTypeAndId,
    				"aimType": 4
    			},//数据，这里使用的是Json格式进行传输  
    			success : function(result) {//返回数据根据结果进行相应的处理 
    				if(result.flag==true){
    					var qaAmounts = result.qaAmounts;
    					layui.$.each(qaAmounts ,function (index, amount){
    						monthArr.push(amount.belongsMonth+"月");                     
    						planAmount.push(amount.curMonthPlanTts);                     
    						finishAmount.push(amount.curMonthFinishTts);
                        });
   						if(monthArr.length == 0){
   							monthArr = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
   						}
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			} 
    		});
	        var echnormprofit = [], normprofit = [
	          {
	            title : {
	              text: $('select[id="query_select_orgId"] option:selected').text()+"-"+year+'年-管理净利润月度走势',
	              x: 'center',
	              subtext: '单位：万元'
	            },
	            tooltip : {
	              trigger: 'axis'
	            },
	            legend: {
	              data:['月度计划','月度完成'],
	              x: 'right'
	            },
	            calculable : true,
	            xAxis : [
	              {
	                type : 'category',
	                boundaryGap : false,
	                data : monthArr
	              }
	            ],
	            yAxis : [
	              {
	                type : 'value'
	              }
	            ],
	            series : [
	              {
	                name:'月度计划',
	                type:'line',
	                data:planAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              },
	              {
	                name:'月度完成',
	                type:'line',
	                itemStyle: {
	                	normal:{color:'#d48265'}
	                },
	                data:finishAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              }
	            ]
	          }
	        ]
	        ,elemnormprofit = $('#LAY-index-profit').children('div');
	        if(!elemnormprofit[index]) return;
          	echnormprofit[index] = echarts.init(elemnormprofit[index], layui.echartsTheme);
          	echnormprofit[index].setOption(normprofit[index]);
          	window.onresize = echnormprofit[index].resize;
        };
        
	    //投资性现金流入
        function rendernormcashin(index,year,orgTypeAndId){
        	var monthArr = [];
        	var planAmount = [];
			var finishAmount = [];
        	$.ajax({
    			type : "POST", //提交方式  
    			async: false,
    			url : "${ctx}/qaConsole/getQaAmountByYearAndId",//路径  
    			data : {
    				"year" : year,
    				"orgTypeAndId" : orgTypeAndId,
    				"aimType": 9
    			},//数据，这里使用的是Json格式进行传输  
    			success : function(result) {//返回数据根据结果进行相应的处理 
    				if(result.flag==true){
    					var qaAmounts = result.qaAmounts;
    					layui.$.each(qaAmounts ,function (index, amount){
    						monthArr.push(amount.belongsMonth+"月");                     
    						planAmount.push(amount.curMonthPlanTts);                     
    						finishAmount.push(amount.curMonthFinishTts);
                        });
   						if(monthArr.length == 0){
   							monthArr = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
   						}
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			} 
    		});
	        var echnormcashin = [], normcashin = [
	          {
	            title : {
	              text: $('select[id="query_select_orgId"] option:selected').text()+"-"+year+'年-投资性现金流入月度走势',
	              x: 'center',
	              subtext: '单位：万元'
	            },
	            tooltip : {
	              trigger: 'axis'
	            },
	            legend: {
	              data:['月度计划','月度完成'],
	              x: 'right'
	            },
	            calculable : true,
	            xAxis : [
	              {
	                type : 'category',
	                boundaryGap : false,
	                data : monthArr
	              }
	            ],
	            yAxis : [
	              {
	                type : 'value'
	              }
	            ],
	            series : [
	              {
	                name:'月度计划',
	                type:'line',
	                data:planAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              },
	              {
	                name:'月度完成',
	                type:'line',
	                itemStyle: {
	                	normal:{color:'#d48265'}
	                },
	                data:finishAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              }
	            ]
	          }
	        ]
	        ,elemnormcashin = $('#LAY-index-cashin').children('div');
	        if(!elemnormcashin[index]) return;
          	echnormcashin[index] = echarts.init(elemnormcashin[index], layui.echartsTheme);
          	echnormcashin[index].setOption(normcashin[index]);
          	window.onresize = echnormcashin[index].resize;
        };
        
	    //投资性现金流出
        function rendernormcashout(index,year,orgTypeAndId){
        	var monthArr = [];
        	var planAmount = [];
			var finishAmount = [];
        	$.ajax({
    			type : "POST", //提交方式  
    			async: false,
    			url : "${ctx}/qaConsole/getQaAmountByYearAndId",//路径  
    			data : {
    				"year" : year,
    				"orgTypeAndId" : orgTypeAndId,
    				"aimType": 10
    			},//数据，这里使用的是Json格式进行传输  
    			success : function(result) {//返回数据根据结果进行相应的处理 
    				if(result.flag==true){
    					var qaAmounts = result.qaAmounts;
    					layui.$.each(qaAmounts ,function (index, amount){
    						monthArr.push(amount.belongsMonth+"月");                     
    						planAmount.push(amount.curMonthPlanTts);                     
    						finishAmount.push(amount.curMonthFinishTts);
                        });
   						if(monthArr.length == 0){
   							monthArr = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
   						}
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			} 
    		});
	        var echnormcashout = [], normcashout = [
	          {
	            title : {
	              text: $('select[id="query_select_orgId"] option:selected').text()+"-"+year+'年-投资性现金流出月度走势',
	              x: 'center',
	              subtext: '单位：万元'
	            },
	            tooltip : {
	              trigger: 'axis'
	            },
	            legend: {
	              data:['月度计划','月度完成'],
	              x: 'right'
	            },
	            calculable : true,
	            xAxis : [
	              {
	                type : 'category',
	                boundaryGap : false,
	                data : monthArr
	              }
	            ],
	            yAxis : [
	              {
	                type : 'value'
	              }
	            ],
	            series : [
	              {
	                name:'月度计划',
	                type:'line',
	                data:planAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              },
	              {
	                name:'月度完成',
	                type:'line',
	                itemStyle: {
	                	normal:{color:'#d48265'}
	                },
	                data:finishAmount,
	                markPoint : {
	                  data : [{type : 'max', name: '最大值'},{type : 'min', name: '最小值'}]
	                },
	                markLine : {
	                  data : [{type : 'average', name: '平均值'}]
	                }
	              }
	            ]
	          }
	        ]
	        ,elemnormcashout = $('#LAY-index-cashout').children('div');
	        if(!elemnormcashout[index]) return;
          	echnormcashout[index] = echarts.init(elemnormcashout[index], layui.echartsTheme);
          	echnormcashout[index].setOption(normcashout[index]);
          	window.onresize = echnormcashout[index].resize;
        };
        
        //指标完成率柱状图
        function renderNormcol(index,month,orgTypeAndId){
			var monthRate = [];
			var addupRate = [];
			var allRate = [];
			var xAxis = ['合同额','融资额','投资额','管理净利润'];
			var orgType = orgTypeAndId.split("-")[1];
			if(orgType == '2'||orgType == '3'){
				xAxis = ['融资额','投资额','管理净利润'];
			}
        	$.ajax({
    			type : "POST", //提交方式  
    			async: false,
    			url : "${ctx}/qaConsole/getQaRateByMonthAndId",//路径  
    			data : {
    				"stsMonth" : month,
    				"orgTypeAndId" : orgTypeAndId
    			},//数据，这里使用的是Json格式进行传输  
    			success : function(result) {//返回数据根据结果进行相应的处理 
    				if(result.flag==true){
    					var qaRates = result.qaRates;
    					layui.$.each(qaRates ,function (index, rate){
    						monthRate.push(rate.curMonthRate);                     
    						addupRate.push(rate.yearAddupRate);                     
    						allRate.push(rate.yearAllRate);                   
                        });
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			} 
    		});
        	var echnormcol = [], normcol = [
          	{
              title : {
                text: $('select[id="query_select_orgId"] option:selected').text()+"-"+month+'-经营质量指标完成率',
                x: 'center'
              },
              tooltip : {
                trigger: 'axis'
              },
              legend: {
                data:['月度完成率','月累完成率','年度完成率'],
                x: 'right',
                y: '32px'
              },
              calculable : true,
              xAxis : [
                {
                  type : 'category',
                  data : xAxis
                }
              ],
              yAxis : [
                {
                  type : 'value',
                 	axisLabel : {
                         formatter: '{value} %'
                     }
                }
              ],
              series : [
                {
                  name:'月度完成率',
                  type:'bar',
                  data:monthRate,
                  markPoint : {
                    data : [
                      {type : 'max', name: '最大值'},
                      {type : 'min', name: '最小值'}
                    ]
                  },
                  markLine : {
                    data : [{type : 'average', name: '平均值'}]
                  }
                },
                {
                  name:'月累完成率',
                  type:'bar',
                  itemStyle: {
                  	normal:{color:'#d48265'}
                  },
                  data:addupRate,
                  markPoint : {
                    data : [
                      {type : 'max', name: '最大值'},
                      {type : 'min', name: '最小值'}
                    ]
                  },
                  markLine : {
                    data : [
                      {type : 'average', name : '平均值'}
                    ]
                  }
                },
                {
                  name:'年度完成率',
                  type:'bar',
                  data:allRate,
                  markPoint : {
                    data : [
                      {type : 'max', name: '最大值'},
                      {type : 'min', name: '最小值'}
                    ]
                  },
                  markLine : {
                    data : [
                      {type : 'average', name : '平均值'}
                    ]
                  }
               	}
              ]
           	}
          	],elemNormcol = $('#LAY-index-month').children('div');
        	if(!elemNormcol[index]) return;
          	echnormcol[index] = echarts.init(elemNormcol[index], layui.echartsTheme);
          	echnormcol[index].setOption(normcol[index]);
          	window.onresize = echnormcol[index].resize;
        };
        var month = $('#sts_month_id').val();
    	var orgTypeAndId = $('#query_select_orgId').val();
        renderNormcol(0,month,orgTypeAndId);
  });
  	
  </script>
</body>
</html>

